<?php
namespace app\common\model;
use think\Model;
class LoadData extends Model{
    /**
     * @param array $data
     * 插入数据
     */
    static public function insert_data($data=[]){
        try{
            $file_name = request()->time();
            //把数据生成sql
            \think\Loader::import('LoadData.LoadData');
            $load_data = new \LoadData();
            if(!empty($data)){
                foreach ($data as $key=>$value){
                    $load_data->create_sql($value['val'], ['table' => $value['table'], 'file_name' => $file_name]);
                }
                return $load_data->import_sql($file_name);
            }
            return false;
        }catch(\Exception $e){
            return false;
        }
    }
}